package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

@SuppressWarnings("serial")
public class CheckFromServlet extends HttpServlet {
	
	
	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
//		request.setCharacterEncoding("utf-8");

		
		
		String username = request.getParameter("username");
		System.out.println(username);
		
		String password = request.getParameter("password");
		System.out.println(password);
		
		String hobby = request.getParameter("hobby");
		System.out.println(hobby);
		
		String sex = request.getParameter("sex");
		System.out.println(sex);
		
		String address = request.getParameter("address");
		System.out.println(address);
		
		String hiddenmoney = request.getParameter("hiddenmoney");
		System.out.println(hiddenmoney);
		
		String introdution = request.getParameter("introdution");
		System.out.println(introdution);
		
		
		response.setCharacterEncoding("text/html;charset=utf-8");
		//模拟插入成功
		int counter=1;
				
		//模拟成功添加
		Map<String,String> rs=new HashMap<String,String>();
		rs.put("counter", "1");
		rs.put("消息", "添加成功");
		
		response.setContentType("text/html;charset=utf-8");
		PrintWriter writer = response.getWriter();
		Gson json=new Gson();
		String jsonString = json.toJson(rs);
		writer.write(jsonString);
			
		}
		
		

}
